|
RAIS
3.2
|
00001 using System; 00002 using System.Collections.Generic; 00003 using System.Text; 00004 using NUnit.Framework; 00005 using RAIS.Common.UserManagement; 00006 using RAIS.DataAccessLayer; 00007 00008 namespace RAIS.DataAccessLayerTest.CommonClasses 00009 { 00010 [TestFixture] 00011 public class UserDataTest 00012 { 00013 private int expectedID = 1; 00014 private string expectedName = "Test Complete Name"; 00015 private string expectedLogin = "testLogin"; 00016 private string expectedPassword = "testPassword"; 00017 private string expectedCompleteName = "Test Complete Name"; 00018 private string expectedEmail = "test@email.com"; 00019 private bool expectedLocked = false; 00020 private string expectedTypeText = "Public Body"; 00021 private int expectedDataRoleType = (int)UserData.DataRoleIndication.DataRole; 00022 private string expectedLanguage = "English"; 00023 private string expectedDataRoleName = "Test Data Role"; 00024 private DataRole expectedDataRole = new DataRole(); 00025 private string expectedFunctionRoleName = "Test Function Role"; 00026 private FunctionRole expectedFunctionRole = new FunctionRole(); 00027 private string expectedFacilityName = "Test Facility"; 00028 private Facility expectedFacility = new Facility(); 00029 00030 private UserData userData; 00031 00032 [SetUp] 00033 public void Init() 00034 { 00035 // Initialize UserTypeDictionary of UserDataClass 00036 UserManagement userManagement = new UserManagement(); 00037 00038 userData = new UserData(); 00039 userData.ID = this.expectedID; 00040 userData.Name = this.expectedName; 00041 userData.Login = this.expectedLogin; 00042 userData.Password = this.expectedPassword; 00043 userData.CompleteName = this.expectedCompleteName; 00044 userData.Email = this.expectedEmail; 00045 //userData.Locked = this.expectedLocked; 00046 userData.TypeText = this.expectedTypeText; 00047 userData.DataRoleType = this.expectedDataRoleType; 00048 userData.DataRole = expectedDataRole; 00049 userData.DataRole.Name = expectedDataRoleName; 00050 userData.FunctionalRole = expectedFunctionRole; 00051 userData.FunctionalRole.Name = expectedFunctionRoleName; 00052 userData.Facility = expectedFacility; 00053 userData.Facility.Name = expectedFacilityName; 00054 } 00055 [Test] 00056 public void UserTypes_Count() 00057 { 00058 // Preparation 00059 int expectedCount = 5; 00060 00061 // Test 00062 Assert.AreEqual(expectedCount, UserData.UserTypes.Count); 00063 } 00064 /*[Test] 00065 public void UserTypes_Administrator() 00066 { 00067 // Preparations 00068 int expectedID = 1; 00069 UserData.UserType expectedType = UserData.UserType.Admin; 00070 string expectedVisibleName = "Administrator"; 00071 00072 // Test 00073 UserTypeData userTypeData = UserData.UserTypes[expectedVisibleName]; 00074 00075 // Checks 00076 Assert.AreEqual(expectedID, userTypeData.ID); 00077 Assert.AreEqual(expectedType, userTypeData.Type); 00078 Assert.AreEqual(expectedVisibleName, userTypeData.VisibleName); 00079 }*/ 00080 [Test] 00081 public void UserTypes_Regulator() 00082 { 00083 // Preparations 00084 int expectedID = 2; 00085 UserData.UserType expectedType = UserData.UserType.Regulator; 00086 string expectedVisibleName = "Regulator"; 00087 00088 // Test 00089 UserTypeData userTypeData = UserData.UserTypes[expectedVisibleName]; 00090 00091 // Checks 00092 Assert.AreEqual(expectedID, userTypeData.ID); 00093 Assert.AreEqual(expectedType, userTypeData.Type); 00094 Assert.AreEqual(expectedVisibleName, userTypeData.VisibleName); 00095 } 00096 [Test] 00097 public void UserTypes_Licensee() 00098 { 00099 // Preparations 00100 int expectedID = 3; 00101 UserData.UserType expectedType = UserData.UserType.Licensee; 00102 string expectedVisibleName = "Licensee"; 00103 00104 // Test 00105 UserTypeData userTypeData = UserData.UserTypes[expectedVisibleName]; 00106 00107 // Checks 00108 Assert.AreEqual(expectedID, userTypeData.ID); 00109 Assert.AreEqual(expectedType, userTypeData.Type); 00110 Assert.AreEqual(expectedVisibleName, userTypeData.VisibleName); 00111 } 00112 /*[Test] 00113 public void UserTypes_PublicBody() 00114 { 00115 // Preparations 00116 int expectedID = 4; 00117 UserData.UserType expectedType = UserData.UserType.PublicBody; 00118 string expectedVisibleName = "Public Body"; 00119 00120 // Test 00121 UserTypeData userTypeData = UserData.UserTypes[expectedVisibleName]; 00122 00123 // Checks 00124 Assert.AreEqual(expectedID, userTypeData.ID); 00125 Assert.AreEqual(expectedType, userTypeData.Type); 00126 Assert.AreEqual(expectedVisibleName, userTypeData.VisibleName); 00127 }*/ 00128 [Test] 00129 public void UserTypes_Guest() 00130 { 00131 // Preparations 00132 int expectedID = 5; 00133 UserData.UserType expectedType = UserData.UserType.Guest; 00134 string expectedVisibleName = "Guest"; 00135 00136 // Test 00137 UserTypeData userTypeData = UserData.UserTypes[expectedVisibleName]; 00138 00139 // Checks 00140 Assert.AreEqual(expectedID, userTypeData.ID); 00141 Assert.AreEqual(expectedType, userTypeData.Type); 00142 Assert.AreEqual(expectedVisibleName, userTypeData.VisibleName); 00143 } 00144 [Test] 00145 public void GetID() 00146 { 00147 // Test 00148 Assert.AreEqual(this.expectedID, this.userData.ID); 00149 } 00150 [Test] 00151 public void GetName() 00152 { 00153 // Test 00154 Assert.AreEqual(this.expectedName, this.userData.Name); 00155 } 00156 [Test] 00157 public void GetLogin() 00158 { 00159 // Test 00160 Assert.AreEqual(this.expectedLogin, this.userData.Login); 00161 } 00162 [Test] 00163 public void GetPassword() 00164 { 00165 // Test 00166 Assert.AreEqual(this.expectedPassword, this.userData.Password); 00167 } 00168 [Test] 00169 public void GetCompleteName() 00170 { 00171 // Test 00172 Assert.AreEqual(this.expectedCompleteName, this.userData.CompleteName); 00173 } 00174 [Test] 00175 public void GetEmail() 00176 { 00177 // Test 00178 Assert.AreEqual(this.expectedEmail, this.userData.Email); 00179 } 00180 [Test] 00181 public void GetLocked() 00182 { 00183 // Test 00184 Assert.AreEqual(this.expectedLocked, this.userData.Locked); 00185 } 00186 [Test] 00187 public void GetUserType() 00188 { 00189 // Test 00190 Assert.AreEqual(UserData.UserTypes[this.userData.TypeText], this.userData.Type); 00191 } 00192 [Test] 00193 public void GetTypeText() 00194 { 00195 // Test 00196 Assert.AreEqual(this.expectedTypeText, this.userData.TypeText); 00197 } 00198 [Test] 00199 public void GetDataRoleType() 00200 { 00201 // Test 00202 Assert.AreEqual(this.expectedDataRoleType, this.userData.DataRoleType); 00203 } 00204 [Test] 00205 public void GetDataRoleSpecified() 00206 { 00207 // Test 00208 Assert.IsTrue(this.userData.DataRoleSpecified); 00209 } 00210 [Test] 00211 public void GetFacilitySpecified() 00212 { 00213 // Test 00214 Assert.IsFalse(this.userData.FacilitySpecified); 00215 } 00216 [Test] 00217 public void GetLanguage() 00218 { 00219 // Test 00220 Assert.AreEqual(this.expectedLanguage, this.userData.Language); 00221 } 00222 [Test] 00223 public void GetDataRole() 00224 { 00225 // Test 00226 Assert.AreEqual(this.expectedDataRole, this.userData.DataRole); 00227 } 00228 [Test] 00229 public void GetFunctionRole() 00230 { 00231 // Test 00232 Assert.AreEqual(this.expectedFunctionRole, this.userData.FunctionalRole); 00233 } 00234 [Test] 00235 public void GetFacility() 00236 { 00237 // Test 00238 Assert.AreEqual(this.expectedFacility, this.userData.Facility); 00239 } 00240 [Test] 00241 public void SetName() 00242 { 00243 // Preparation 00244 string expectedNewName = "New Test UserData"; 00245 00246 // Test 00247 this.userData.Name = expectedNewName; 00248 00249 // Check 00250 Assert.AreEqual(expectedNewName, this.userData.Name); 00251 } 00252 [Test] 00253 public void SetLogin() 00254 { 00255 // Preparation 00256 string expectedNewLogin = "newTestLogin"; 00257 00258 // Test 00259 this.userData.Login = expectedNewLogin; 00260 00261 // Check 00262 Assert.AreEqual(expectedNewLogin, this.userData.Login); 00263 } 00264 [Test] 00265 public void SetPassword() 00266 { 00267 // Preparation 00268 string expectedNewPassword = "newTestPassword"; 00269 00270 // Test 00271 this.userData.Password = expectedNewPassword; 00272 00273 // Check 00274 Assert.AreEqual(expectedNewPassword, this.userData.Password); 00275 } 00276 [Test] 00277 public void SetCompleteName() 00278 { 00279 // Preparation 00280 string expectedNewCompleteName = "New Test Complete Name"; 00281 00282 // Test 00283 this.userData.CompleteName = expectedNewCompleteName; 00284 00285 // Check 00286 Assert.AreEqual(expectedNewCompleteName, this.userData.CompleteName); 00287 } 00288 [Test] 00289 public void SetEmail() 00290 { 00291 // Preparation 00292 string expectedNewEmail = "newTestEmail@test.com"; 00293 00294 // Test 00295 this.userData.Email = expectedNewEmail; 00296 00297 // Check 00298 Assert.AreEqual(expectedNewEmail, this.userData.Email); 00299 } 00300 /*[Test] 00301 public void Locked() 00302 { 00303 // Preparation 00304 bool expectedNewLocked = true; 00305 00306 // Test 00307 this.userData.Locked = expectedNewLocked; 00308 00309 // Check 00310 Assert.AreEqual(expectedNewLocked, this.userData.Locked); 00311 }*/ 00312 [Test] 00313 public void SetTypeText() 00314 { 00315 // Preparation 00316 string expectedNewTypeText = "Regulator"; 00317 00318 // Test 00319 this.userData.TypeText = expectedNewTypeText; 00320 00321 // Check 00322 Assert.AreEqual(expectedNewTypeText, this.userData.TypeText); 00323 } 00324 [Test] 00325 public void SetDataRoleType() 00326 { 00327 // Preparation 00328 int expectedNewDataRoleType = (int)UserData.DataRoleIndication.Facility; 00329 00330 // Test 00331 this.userData.DataRoleType = expectedNewDataRoleType; 00332 00333 // Check 00334 Assert.AreEqual(expectedNewDataRoleType, this.userData.DataRoleType); 00335 } 00336 [Test] 00337 public void SetLanguage() 00338 { 00339 // Preparation 00340 string expectedNewLanguage = "Arabic"; 00341 00342 // Test 00343 this.userData.Language = expectedNewLanguage; 00344 00345 // Check 00346 Assert.AreEqual(expectedNewLanguage, this.userData.Language); 00347 } 00348 [Test] 00349 public void SetDataRole() 00350 { 00351 // Preparation 00352 DataRole expectedNewDataRole = new DataRole(); 00353 expectedNewDataRole.Name = "New Test Data Role"; 00354 00355 // Test 00356 this.userData.DataRole = expectedNewDataRole; 00357 00358 // Check 00359 Assert.AreEqual(expectedNewDataRole, this.userData.DataRole); 00360 } 00361 [Test] 00362 public void SetFunctionRole() 00363 { 00364 // Preparation 00365 FunctionRole expectedNewFunctionRole = new FunctionRole(); 00366 expectedNewFunctionRole.Name = "New Test Function Role"; 00367 00368 // Test 00369 this.userData.FunctionalRole = expectedNewFunctionRole; 00370 00371 // Check 00372 Assert.AreEqual(expectedNewFunctionRole, this.userData.FunctionalRole); 00373 } 00374 [Test] 00375 public void SetFacility() 00376 { 00377 // Preparation 00378 Facility expectedNewFacility = new Facility(); 00379 expectedNewFacility.Name = "New Test Facility"; 00380 00381 // Test 00382 this.userData.Facility = expectedNewFacility; 00383 00384 // Check 00385 Assert.AreEqual(expectedNewFacility, this.userData.Facility); 00386 } 00387 } 00388 }